<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.io.IOException" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Using Users</title>
</head>
<body>
<%
	UserService userService = UserServiceFactory.getUserService();
	
	if ( userService.isUserLoggedIn() ) {
		
		User user = userService.getCurrentUser();
		
	    out.println("<ul><li>Nickname: " + user.getNickname());
	    out.println("<li>AuthDomain: " + user.getAuthDomain());
	    out.println("<li>Email: " + user.getEmail());
	    out.println("<li>FederatedIdentity: " + user.getFederatedIdentity());
	    out.println("<li>UserId: " + user.getUserId());
//	    out.println("<li>Class: " + user.getClass());
	    out.println("<li>UserAdmin: " + userService.isUserAdmin());
	    out.println("<li><a href='"+userService.createLogoutURL(request.getRequestURI())+"'>로그아웃</a>");
	    out.println("</ul>");
	    
	    pageContext.setAttribute("user", user);
	    
	} else {
		
		out.println("<a href='"+userService.createLoginURL(request.getRequestURI())+"'>로그인</a>");
		
	}
	
	 out.println("<p>UserLoggedIn: " + userService.isUserLoggedIn()+"</p>");
%>
<p>https://developers.google.com/appengine/docs/java/gettingstarted/usingusers</p>
</body>
</html>